<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生选题</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
    if (!localStorage.getItem("Authorization")) {
            alert("请先登录")
            window.location.href = "../html/index.html";
        } else {
            const verificationUrl = `http://localhost/verify?token=${localStorage.getItem("Authorization")}&url=${window.location.href}`;

            axios.get(verificationUrl)
                .then((response) => {
                    const code = response.data.code
                    const role = response.data.data;
                    if (code === 0 && role === 0) {

                    } else {
                        alert("您没有足够的权限访问此页面");
                        window.location.href = "../html/index.html";
                    }
                })
                .catch((error) => {
                    console.error("Error:", error);
                    window.location.href = "../html/index.html";
                });
        }
    </script>
    <script src="../js/student.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/teacher.css">
</head>

<body>
<h1>学生选题页面</h1>

<form onsubmit="return false;" method="get">
    <label for="subjectName">课题名:</label>
    <input type="text" id="subjectName" name="subjectName">

    <label for="showAll">查询全部:</label>
    <input type="checkbox" id="showAll" name="showAll" value="1">

    <label for="teacherName">教师名:</label>
    <input type="text" id="teacherName" name="teacherName">

    <label for="orderBy">排序字段:</label>
    <select id="orderBy" name="orderBy">
        <option value="id">课题ID</option>
        <option value="difficulty">难度</option>
    </select>

    <label for="desc">降序</label>
    <input type="checkbox" id="desc" name="desc" value="1">

    <br>

    <label for="page">分页</label>
    <input type="number" id="page" name="page" min="1">

    <label for="pageSize">每页大小:</label>
    <select id="pageSize" name="pageSize">
        <option value="10">10</option>
        <option value="20">20</option>
        <option value="30">30</option>
    </select>

    <br>
    <button id="queryBtn" type="submit" onclick="queryAllSubject()">查询</button>
    <button id="queryMyBtn" type="submit" onclick="queryMySubject()">我的课题</button>
</form>

<div id="subjectList">
    <table>
        <thead>
        <tr>
            <th>课题ID</th>
            <th>课题名称</th>
            <th>难度</th>
            <th>是否已选</th>
            <th>待选学生姓名</th>
            <th>已选学生姓名</th>
            <th>教师姓名</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <!-- 这里将显示查询出的课题 -->
        </tbody>
    </table>
</div>

</body>
<script>

</script>
</html>

</body>
</html>